exports.install = function (Vue) {
    Vue.prototype.categoryInfo = {
        categoryArray: []
    };
    // 从后台获取数据
    Vue.prototype.getProductType = function () {
        this.axios
            .post("http://localhost:8081/category/getTree?id=0")
            .then(res => {
                // 将获得到的数据赋值给options
                this.categoryInfo.categoryArray = this.getTreeData(res.data.object);
                console.log(this.categoryInfo.categoryArray)
            });
    };
    // 递归方法
    Vue.prototype.getTreeData = function (object) {
        // 循环遍历json数据
        for (var i = 0; i < object.length; i++) {
            if (!object[i].children) {
                // children若为空数组，则将children设为undefined
                object[i].children = undefined;
            } else {
                // children若不为空数组，则继续 递归调用 本方法
                this.getTreeData(object[i].children);
            }
        }
        return object;
    }
}
